<?php defined('SYSPATH') or die('No direct script access.');

// Все, что не относится к другим контроллерам, пишем сюда.
class Controller_Main extends Controller_Base
{
	public function action_index()
	{    
        $books = $this->book_model->get_global_popular_books(12);
        $this->main_model->transliterate_array($books, 'name');
        
        $title   = 'Главная';
        $content = new View('index_tpl');
        $content->books = $books;
        $this->slider = true;
        
        $menu = $this->category_model->get_top_categories();
        $this->main_model->transliterate_array($menu, 'name');
        		
        $this->print_template($title, $content, $menu);
	}
    
    public function action_search()
    {
        $query = strip_tags($this->request->param('query')); 
        
        $books = $this->book_model->search($query);
        $this->main_model->transliterate_array($books, 'name');
        
        $title   = 'Поиск - '.$query;
        $content = new View('search_tpl');
        $content->books = $books;
        $content->query = $query;
        
        $menu = $this->category_model->get_top_categories();
        $this->main_model->transliterate_array($menu, 'name');
        
        $this->print_template($title, $content, $menu);
    }
    
    public function action_test()
    {
        $title   = '2312321';
        $content = new View('subcategory_tpl');
        
        $this->print_template($title, $content);
    }

} // End Main
